package com.bauer.java.spring.transaction.service.impl;

import com.bauer.java.spring.transaction.mapper.BaseMenuMapper;
import com.bauer.java.spring.transaction.model.UserModel;
import com.bauer.java.spring.transaction.model.po.BaseMenu;
import com.bauer.java.spring.transaction.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * @Author ：rui.wei
 * @Date ：Created in 15:43 2019/7/3
 * @Description：
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private BaseMenuMapper baseMenuMapper;

    @Override
    @Transactional(rollbackFor = Exception.class, propagation = Propagation.SUPPORTS)
    public void updateMenu() {
        BaseMenu baseMenu = new BaseMenu();
        baseMenu.setId(1L);
        baseMenu.setGmtModify(new Date());
        baseMenu.setMenuName("nameModify");
        baseMenuMapper.updateByPrimaryKey(baseMenu);
        System.out.println("baseMenu updated");
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveUser(UserModel userModel) {

    }
}
